<template>
  <div class="collect">
    <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="onLoad"
          >
      <div class="item" @click="godetails(item.goods_id)" v-for="(item,index) in collect" :key="index">
        <div class="item-l">
          <div class="shopimg">
            <img :src="item.goods_thumb" />
          </div>
          <div class="shopage">
            <p class="p1">{{item.goods_name}}</p>
            <p class="p3" v-if="item.brand_name != ''">厂商：{{item.brand_name}}</p>
            <p class="p4">{{item.price}}</p>
          </div>
        </div>
        <div class="item-r">
          <img src="../../assets/img/mine/gouche.png" />
        </div>
      </div>
    </van-list>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        collect:[],
        // 分页
        loading: false,
        finished: false,
        page:1
      }
    },
    created() {
      this.shoucang(1)
    },
    mounted(){
      
    },
    
    methods: {
      onLoad() {
        setTimeout(() => {
          this.page+=1
          this.shoucang(this.page)
        }, 500);
      },
      // shoucang
      shoucang(page){
        this.$get("api/gzh_mine.php?action=collect_list", {
          uid:localStorage.getItem('uid'),
          page:page
        }).then(res => { 
          
          this.loading=false
          if(page==1){
              if(res.data.length==0){
                  this.finished=true
              }else{
                  this.collect = res.data
              }
              if(res.data.length>0&&res.data.length<10){
                  this.finished=true
                  // this.page = 1
              }
              
          }else{
              if(res.data.length==0){
                  this.finished=true
              }else{
                  for (const key in res.data) {
                      this.collect.push(res.data[key])
                  }
              }
              if(res.data.length>0&&res.data.length<10){
                  this.finished=true
                  // this.page = 1
              }
              
          }
        }).catch(err => {

        });
      },
      godetails(id){
        this.$router.push({name:'details',query: {goods_id:id}}) 
      },

    },
  }
</script>

<style scoped>
.collect {
  width: 100%;
  height: 100%;
  border-top: 1PX solid #E8E8E8;
  min-height: 100vh;
  background: #F6F6F6;
}
.item{
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1PX solid #E8E8E8;
  padding: 0 30px;
  box-sizing: border-box;
  background: #fff;
}
.item-l{
  display: flex;
  align-items: center;
}
.item-l .shopimg{
  width: 146px;
  height: 146px;
  margin-right: 26px;
}
.item-l .shopimg img{
  width: 146px;
  height: 146px;
  border: 1PX solid #f7f7ff;
}
.item-l .shopage .p1{
  font-size: 30px;
  color: #333;
  margin-bottom: 5px;
}
.item-l .shopage .p2{
  font-size: 26px;
  color: #808080;
}
.item-l .shopage .p3{
  font-size: 26px;
  color: #808080;
}
.item-l .shopage .p4{
  font-size: 32px;
  color: #CF1801;
  margin-top: 10px;
}
.item-r{
  width: 54px;
  height: 54px;
}
.item-r img{
  width: 54px;
  height: 54px;
}
</style>
<style>
  .van-list{
      height:100vh;
      width: 100%;
      overflow: hidden;
    overflow-y: scroll;
  }
</style>